package com.hsbc.minicode.combinations_demo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.hsbc.minicode.commom.IntMapLetter;

public class Combination {
	
	
    public Integer[] in;
    
	
	public Combination(Integer[] in){
		this.in=in;
	}
	
	public String print() {
		List<String[]> arrlist=new ArrayList<String[]>();
		for(int i:this.in) {
			String numberstr[]=IntMapLetter.getmap().get(Integer.valueOf(i));
			arrlist.add(numberstr);
		}
		
		List<String> arrStringlist=new ArrayList<String>();
		String astr="";
		for(int n=0;n<arrlist.size();n++) {
			String[] arr= arrlist.get(n);
			
				if(arrStringlist!=null&&arrStringlist.size()==0) {
					for(String sa:arr) {
					  arrStringlist.add(sa);
					}
					
				}else {
					
						List<String> slist=new ArrayList<String>();
						for(String s:arrStringlist) {
							for(String sa:arr) {
								astr=s+sa;
								slist.add(astr);
							}
						}
						arrStringlist.addAll(slist);
								
				
			}
		}
		int len=this.in.length;
		List<String> relist=new ArrayList<String>();
		for(int i=0;i<arrStringlist.size();i++){
			String emu=arrStringlist.get(i);
			if(emu.length()==len){
				relist.add(emu);
			}
		}
		String[] strings = relist.toArray(new String[relist.size()]);	
		return Arrays.toString(strings);
	}

}
